import 'package:flutter/material.dart';

class PageViewPage extends StatefulWidget {
  const PageViewPage({super.key});

  @override
  State<PageViewPage> createState() => _PageViewPageState();
}

class _PageViewPageState extends State<PageViewPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("pageview演示"),
      ),
      body: PageView(
        scrollDirection: Axis.vertical, // 滑动方向为垂直方向
        allowImplicitScrolling: true,
        children: [
          Center(
            child: Text(
              "1",
              style: Theme.of(context).textTheme.headlineSmall,
            ),
          ),
          Center(
            child: Text(
              "2",
              style: Theme.of(context).textTheme.headlineSmall,
            ),
          ),
          Center(
            child: Text(
              "3",
              style: Theme.of(context).textTheme.headlineSmall,
            ),
          ),
          Center(
            child: Text(
              "4",
              style: Theme.of(context).textTheme.headlineSmall,
            ),
          ),
          Center(
            child: Text(
              "5",
              style: Theme.of(context).textTheme.headlineSmall,
            ),
          ),
          Center(
            child: Text(
              "6",
              style: Theme.of(context).textTheme.headlineSmall,
            ),
          )
        ],
        onPageChanged: (index) {
          print(index);
        },
      ),
    );
  }
}
